home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_075 / comm / timer.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  996b  |  46 lines

  1.  
  2. #define  TIMER 1
  3. #include "globals.h"
  4.  
  5. extern struct Task *FindTask(), *MakeTask();
  6.  
  7. int Open_Timer()    /* Open the timer device */
  8. {
  9.    int error;
  10.  
  11.    TimerMsgPort.mp_SigBit = NULL;
  12.  
  13.    if ((error = OpenDevice(TIMERNAME, (long)UNIT_VBLANK, &TimerIO, 0L)) != 0)
  14.       return(error);
  15.  
  16.    /* Set up the message port in the I/O request */
  17.  
  18.    TimerMsgPort.mp_Node.ln_Type = NT_MSGPORT;
  19.    TimerMsgPort.mp_Node.ln_Name = "comm-timer";
  20.    TimerMsgPort.mp_Flags        = 0;
  21.    TimerMsgPort.mp_SigBit       = AllocSignal(-1L);
  22.    TimerMsgPort.mp_SigTask      = FindTask(0L);
  23.  
  24.    AddPort(&TimerMsgPort);
  25.  
  26.    TimerIO.tr_node.io_Message.mn_ReplyPort = &TimerMsgPort;
  27.    return(0);
  28. }
  29.  
  30. Close_Timer()
  31. {
  32.    CloseDevice(&TimerIO);
  33.    RemPort(&TimerMsgPort);
  34. }
  35.  
  36. StartTimer(seconds, micros)
  37. ULONG seconds, micros;
  38. {
  39.    TimerIO.tr_node.io_Command = TR_ADDREQUEST;
  40.    TimerIO.tr_node.io_Flags   = IOF_QUICK;
  41.    TimerIO.tr_time.tv_secs    = seconds;
  42.    TimerIO.tr_time.tv_micro   = micros;
  43.    SendIO(&TimerIO);
  44. }
  45.  
  46.